package com.nightsoul.springboottest2.controller;

import java.util.UUID;

import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisHttpSessionController {

	@RequestMapping("/redis/uuid")
	public String uuid(HttpSession httpSession) {
		UUID uuid = (UUID) httpSession.getAttribute("uuid");
		if(uuid == null) {
			uuid = UUID.randomUUID();
		}
		httpSession.setAttribute("uuid", uuid);
		return httpSession.getId();
	}
}
